Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Critical issues leave CLI commands using a stale executable path after version changes and cause repair to attempt registration instead of installing a trusted package when only a developer-signed package is present.
2 open issues
What changed in this PR
Moves PowerShell CLI-backed commands to centralized WinGet package discovery through Windows APIs, using the Store-signed executable in production while retaining alias activation for development.
Changes:
- Centralizes executable resolution and updates CLI callers.
- Adds Windows API projections and adjusts integrity checks and tests.
- Updates the release note to cover all CLI-backed commands.
| File | Description |
|---|---|
| src/PowerShell/tests/RunTests.ps1 | Narrows Pester test selection. |
| src/PowerShell/tests/Microsoft.WinGet.Client.Integrity.Tests.ps1 | Removes mocked integrity tests. |
| src/PowerShell/Microsoft.WinGet.UnitTests/WinGetIntegrityTests.cs | Removes the obsolete constructor test. |
| src/PowerShell/Microsoft.WinGet.UnitTests/WingetCLIWrapperTests.cs | Moves trust-filter tests to the wrapper. |
| src/PowerShell/Microsoft.WinGet.UnitTests/Microsoft.WinGet.UnitTests.csproj | Adds an engine reference alias. |
| src/PowerShell/Microsoft.WinGet.Client.Engine/Microsoft.WinGet.Client.Engine.csproj | Adds package-discovery API projections. |
| src/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/WinGetVersion.cs | Uses centralized executable resolution. |
| src/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/WingetCLIWrapper.cs | Discovers and caches the packaged executable path. |
| src/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/AppxModuleHelper.cs | Removes trust-filtered PowerShell discovery. |
| src/PowerShell/Microsoft.WinGet.Client.Engine/Common/WinGetIntegrity.cs | Updates executable and diagnostic lookups. |
| src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/UserSettingsCommand.cs | Uses the parameterless CLI wrapper. |
| src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/CliCommand.cs | Uses the parameterless CLI wrapper. |
| doc/release-notes/1.31/powershell-winget-path-resolution.md | Broadens the path-resolution release note. |
Review effort: Balanced
| #if USE_PROD_CLSIDS | ||
| string? version = appxModule.GetStoreSignedAppInstallerPropertyValue("Version"); | ||
| #else | ||
| string? version = appxModule.GetAppInstallerPropertyValue("Version"); |
| /// <summary> | ||
| /// Gets the cached path to the installed WinGet executable. | ||
| /// </summary> | ||
| public static string WinGetFullPath => LazyInitializer.EnsureInitialized(ref winGetFullPath, GetWinGetPath) !; |
ranm-msft
left a comment
There was a problem hiding this comment.
One repair-path regression to address before approval.
| /// <summary> | ||
| /// Gets the cached path to the installed WinGet executable. | ||
| /// </summary> | ||
| public static string WinGetFullPath => LazyInitializer.EnsureInitialized(ref winGetFullPath, GetWinGetPath) !; |
There was a problem hiding this comment.
WinGetFullPath caches a versioned WindowsApps path for the PowerShell process lifetime. RepairStateMachineAsync resolves it before deploying a different App Installer version, then re-enters AssertWinGet with the stale path, so the repair reruns the old binary or fails after its removal. Please re-resolve after deployment or avoid caching, and test a version-changing repair followed by another CLI command in the same session.

📖 Description
Move all CLI calling cmdlets to use the packaged path.
Move to using OS APIs to find it so we can do it without piping an invocation around.
🔍 Validation
Kept largely as is, but I did make the package discovery code run in dev mode even if we do end up needing to use the alias to run it (directly running packaged exes only runs them "packaged" when an access-denied error triggers a remediation path).
Microsoft Reviewers: Open in CodeFlow